Skip to content

Refactor shortcut related code & add shortcut tab to settings #3456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

SunderB
Copy link
Contributor

@SunderB SunderB commented May 4, 2025

Hi, it's been a while! I've seen that some work has been done on shortcut configuration, and had some motivation to have a look at it a bit. Hopefully these changes manage to improve/simplify shortcut handling:

Features/bug fixes

  • Move most code related to shortcuts to its own class
    • All default shortcuts are defined using a more standard string format, which can be passed straight into QKeySequence
    • Default and user-defined shortcuts are kept in separate lists, with the user-defined bindings taking priority (only matters if shortcut mode = user)
  • Add new Shortcuts tab to the settings widget
    • Combo box to select the shortcut mode (emacs, windows, mac, user)
    • Shows list of current shortcuts/key bindings
  • When shortcut mode is set to user, create a new config file when exiting if it doesn't exists
  • Tweak some key bindings for consistency and to avoid clashes

WIP: Need to add some text to the shortcut settings tab, test the user shortcut mode, and do a once over of the code.

Screenshots

The current UI is shown below:
Screenshot_20250504_100831

Testing

I'm only able to test this on Debian (Trixie) - it'll probably want testing on Windows/Mac as well.
I'm unsure whether the code I've written is Qt5 compatible, but I assume Qt6 is becoming the main option anyways. I just saw the commit deprecating Qt5, so I'm going to assume using Qt6 features is fine.
Feedback & suggestions are welcome :)

SunderB added 3 commits May 4, 2025 10:33
* All sets of default shortcuts are now defined in one map. Most key bindings are the same, but some have been changed for consistency or to avoid clashes between key bindings.
* Default bindings and user-specified bindings are stored in different lists. The user binding will always take priority over the defaults.
* When the shortcut mode is set to 'user', a mostly blank shortcut configuration file will now be created when exiting the program. Default base is still 'emacs'.
* Functions to update the shortcut key bindings have been added, but not tested. This is to lay the groundwork for a potential shortcut configuration UI in the future.
* Shortcuts prefs tab includes: shortcut mode combo box, and a table showing all the shortcuts & current key bindings.
* Some debug shortcuts have now been made configurable.
* The list of default shortcuts (defaultBindings) is now set in the sonicpi_shortcuts.cpp, as setting it in the header seemed to cause weird issues with QStringList and segmentation faults.
* In SonicPiShortcuts, the shortcut_ids list is now generated at runtime from the keys in defaultBindings.
* Added function to SonicPiShortcuts to get all shortcuts & current key bindings.
* Fix Windows shortcut for Redo.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant